package com.uraurora.crescent.function;

import java.util.Objects;

/**
 * 接收3个参数的无返回值函数式接口
 * @author ：Sei
 * @param <T1>
 * @param <T2>
 * @param <T3>
 */
@FunctionalInterface
public interface Action3<T1, T2, T3> {

    void on(T1 t1, T2 t2, T3 t3);

    default Action3<T1, T2, T3> before(Action3<? super T1, ? super T2, ? super T3> before) {
        Objects.requireNonNull(before);
        return (T1 t1,T2 t2, T3 t3) -> { before.on(t1, t2, t3); on(t1, t2, t3); };
    }

    default Action3<T1, T2, T3> after(Action3<? super T1, ? super T2, ? super T3> after) {
        Objects.requireNonNull(after);
        return (T1 t1,T2 t2, T3 t3) -> { on(t1, t2, t3); after.on(t1, t2, t3); };
    }

    //<editor-fold desc="柯里化与反柯里化">
    default Action2<T2, T3> curry1(T1 t1){
        return (t2, t3) -> on(t1, t2, t3);
    }

    default Action2<T1, T3> curry2(T2 t2){
        return (t1, t3) -> on(t1, t2, t3);
    }

    default Action2<T1, T2> curry3(T3 t3){
        return (t1, t2) -> on(t1, t2, t3);
    }

    default Action1<T3> curry(T1 t1, T2 t2){
        return t3 -> on(t1, t2, t3);
    }
    //</editor-fold>
}
